package com.mygdx.game.own;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector3;

public class KLMainScreen extends ScreenAdapter {

    KLJump game;
    OrthographicCamera guiCam;
    Rectangle soundBounds;
    Rectangle playBounds;
    Rectangle highscoresBounds;
    Rectangle helpBounds;
    Vector3 touchPoint;

    public KLMainScreen(KLJump game) {
        this.game = game;
        guiCam = new OrthographicCamera(480, 320);
        guiCam.position.set(480 / 2, 320/2, 0);
//        soundBounds = new Rectangle(0, 0, 64, 64);
//        playBounds = new Rectangle(160 - 150, 200 + 18, 300, 36);
//        highscoresBounds = new Rectangle(160 - 150, 200 - 18, 300, 36);
//        helpBounds = new Rectangle(160 - 150, 200 - 18 - 36, 300, 36);
        touchPoint = new Vector3();
    }

    public void update(){
        if(Gdx.input.justTouched()){//获取焦点事件
            Gdx.app.log(KLMainScreen.class.getSimpleName(),"输入被监控到");
        }
    }

    public void draw(){
        GL20 gl = Gdx.gl;
        gl.glClearColor(1,0,0,1);
        gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        guiCam.update();
        game.spriteBatch.setProjectionMatrix(guiCam.combined);

        game.spriteBatch.disableBlending();

        //设置背景图
        game.spriteBatch.begin();
        game.spriteBatch.draw(Assets.backgroundRegion, 0, 0, 480, 320);
        game.spriteBatch.end();

        game.spriteBatch.enableBlending();
        game.spriteBatch.begin();
        game.spriteBatch.draw(Assets.mainMenu,140, 180, 180, 240);
        game.spriteBatch.draw(Assets.highScoresRegion,110,100,180,240);
        //game.spriteBatch.draw(Assets.logo, 160 - 274 / 2, 480 - 10 - 142, 274, 142);
//        game.spriteBatch.draw(Assets.mainMenu, 10, 200 - 110 / 2, 300, 110);
        //game.spriteBatch.draw(Settings.soundEnabled ? Assets.soundOn : Assets.soundOff, 0, 0, 64, 64);
        game.spriteBatch.end();

    }

    @Override
    public void render(float delta) {
        draw();
        update();
    }

    @Override
    public void pause() {
        Settings.save();
    }
}
